<div class="page-container" v-cloak>
    <el-card>
        <template #header>
            <div class="breadcrumb" style=" overflow: hidden;">
                <el-breadcrumb separator="/" style=" float: left;  ">
                    <el-breadcrumb-item><a href="{:url('admin/package/index')}">套餐列表</a></el-breadcrumb-item>
                    <el-breadcrumb-item>{$title}</el-breadcrumb-item>
                </el-breadcrumb>
                <el-breadcrumb separator="/" style=" float: right;  ">
                    <el-button type="primary" @click="refresh()">刷新</el-button>
                </el-breadcrumb>
            </div>
        </template>
        <div>
            <el-form label-width="100px">
                <el-form-item label="所属门店">
                    <el-input v-model="form.store_name" disabled></el-input>
                </el-form-item>
                <el-form-item label="套餐名称">
                    <el-input v-model="form.name"></el-input>
                </el-form-item>
                <el-form-item label="套餐价格">
                    <div>
                        <el-input v-model="form.price" type="number"></el-input>
                    </div>
                </el-form-item>
                <el-form-item label="套餐时长">
                    <div>
                        <el-input v-model="form.time" type="number"></el-input>
                    </div>
                </el-form-item>
                <el-form-item label="是否展示">
                    <el-radio-group v-model="form.status">
                        <el-radio :label="1">显示</el-radio>
                        <el-radio :label="0">隐藏</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="套餐类型">
                    <el-radio-group v-model="form.type">
                        <el-radio :label="0">正常套餐</el-radio>
                        <el-radio :label="1">加时套餐</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item>
                        <el-button @click="submitEvent" type="primary">
                        提交
                    </el-button>
                    <el-button @click="goBack" type="warning">
                        返回
                    </el-button>
                </el-form-item>
            </el-form>
        </div>
    </el-card>

</div>
{hcmstag:include file="admin@/components/upload/select-image"}
<script>
    const App = {
        data() {
            return {
                form: {},
                value: [],
            }
        },
        mounted() {
            this.getInfo()
        },
        computed: {},
        methods: {
            handleChange(value) {
                console.log(value);
            },
            richUpdateEvent(e) {
                console.log('richUpdateEvent', e)
            },


            /**
             * 获取编辑所需信息
             */
            getInfo() {
                let package_id = this.getUrlQuery('package_id', 0)
                this.httpGet("{:url('admin/package/edit')}/" + package_id, {}).then(res => {
                    if (res.status) {
                        console.log(res)
                        let {package = {}} = res.data


                        if (package.package_id) {

                            this.form = {
                                ...package,
                            }
                        }

                    }
                })
            },
            /**
             * 提交信息
             */
            submitEvent() {
                this.httpPost("{:url('admin/package/edit')}", {
                    ...this.form,
                }, true).then(res => {
                    if (res.status) {
                        this.$message.success(res.msg)
                        location.href = "{:url('admin/package/index')}"
                    }
                })
            },
            refresh() {
                location.replace(location.href);
            },
            goBack() {
                window.history.back();
            }
        }
    }
</script>

<style>
    /*默认输入框宽度*/
    .el-form-item .el-input {
        width: 500px;
    }

</style>
